﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DreamBuilder.Core;
using DreamBuilder.Core.DAO;
using DreamBuilder.Common;
using System.Data;
using System.Data.Common;

/// <summary>
///CreateInstantDAL 的摘要说明
/// </summary>
public class IMDataHelper : DataAccessBase
{
    public IMDataHelper()
    {
        this.DBHelper = DBHelperFactory.CreateInstance(DbHelperName.Business);
    }

    private static IDBHelper dal = DBHelperFactory.CreateInstance(DbHelperName.Business);


    public static DataSet ExcuteDataSet(string sql)
    {

        return dal.ExecuteDataSet(sql);
    }
    /// <summary>
    /// 保存数据
    /// </summary>
    /// <param name="datatables"></param>
    /// <returns></returns>
    public void InsertData(DataSet ds)
    {
        try
        {
            DataSet dsOut = new DataSet();
            List<string> tableNames = new List<string>();
            List<string> primaryKeys = new List<string>();
            foreach (DataTable dt in ds.Tables)
            {
                tableNames.Add(dt.TableName);
                primaryKeys.Add(dt.PrimaryKey[0].ColumnName);
            }
            SaveData(out dsOut, ds, tableNames.ToArray(), primaryKeys.ToArray(), new IKeyGen[] { null });
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}

